-- liquibase formatted sql

-- changeSet Vladislav:5
create table if not exists project_item(
    item_id int generated by default as identity primary key,
    person_id int references db.public.person(id) on delete cascade not null,
    project_id int references project(project_id) on delete cascade not null,
    code_id int references code(id) on delete set null,
    creation_date timestamp without time zone not null,
    modified_date timestamp without time zone not null,
    name varchar,
    addr_country varchar,
    addr_city varchar,
    addr_street varchar,
    addr_housenumber varchar,
    properties jsonb,
    polygon geometry(Polygon, 4326),
    line geometry(LineString, 4326)
);

create index project_item_person_id_idx on project_item(person_id);
create index project_item_project_id_idx on project_item(project_id);
create index project_item_code_id_idx on project_item(code_id);

-- rollback drop index project_item_person_id_idx;
-- rollback drop index project_item_project_id_idx;
-- rollback drop index project_item_code_id_idx;
-- rollback drop table project_item;